////////////////////////////////////////////////////////////////////////////////////
//
//
//							MiTAC Corporation
//				NO. 187, TIDING BLVD., SEC. 2, TAIPEI, TAIWAN
//
// 			(c) Copyright 2006, MiTAC Corporation, Taipei, Taiwan
//						All rights reserved.
//-------------------------------------------------------------------------------------
//
//	File:	memory.c
//	Description:	dynamic memory allocation
//
//	Programer: Visual.Wei
//	Date: 2007-5-17
//
//////////////////////////////////////////////////////////////////////////////
#include <eboot.h>

extern volatile ROMHDR * pTOC;

static volatile UINT32 dwMMbase=0;

VOID InitMem()
{
	//check TOC
	if (pTOC == (ROMHDR *const) -1)
	{
		OALMSG(OAL_ERROR, (L"Error: pTOC can not found\r\n"));
		while(1); // spin forever!
	}
	OALMSG(OAL_INFO, (L"RAM Start : 0x%08x\r\n", pTOC->ulRAMStart));
	OALMSG(OAL_INFO, (L"RAM Free  : 0x%08x\r\n", pTOC->ulRAMFree));
	OALMSG(OAL_INFO, (L"RAM End   : 0x%08x\r\n", pTOC->ulRAMEnd));

	//init free memory
	memset((LPVOID)(pTOC->ulRAMFree),0,pTOC->ulRAMEnd-pTOC->ulRAMFree);
	dwMMbase=pTOC->ulRAMFree;
}

LPVOID kmalloc(size_t size)
{
	return (LPVOID )dwMMbase;
}
